package com.syxbyi._3game;

public class Card {
    final public Rank rank;
    final public Suit suit;

    public Card(Rank r) {
        this(r, null);
    }

    public Card(Rank r, Suit s) {
        // validity check
        if (r == Rank.JOKER || r == Rank.BLACK) {
            if (s != null) {
                System.out.println("错误！给大小王指定了花色");
            }
        } else {
            if (s == null) {
                System.out.println("错误！非王牌未指定花色");
            }
        }
        rank = r;
        suit = s;
    }

    public void print() {
        System.out.printf("%s%s\n", Suit.toString(suit), Rank.toString(rank));
    }

    @Override
    public String toString() {
        return String.format("%s%s", Suit.toString(suit), Rank.toString(rank));
    }
}
